const Koa = require("koa");
const bodyParser = require("koa-bodyparser");
const cors = require("koa2-cors");
const ormMiddleware = require('./orm-middleware');

const app = new Koa();
app.use(ormMiddleware);
app.use(bodyParser()); // 这样可以接受 application/json 和 application/x-www-form-urlencoded
app.use(cors()); // 允许跨域

const router = require("./router");

app.use(router.routes()).use(router.allowedMethods());
app.listen(3000, () => console.log("应用已经启动"));
